﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RPGMapRevealer
{
    public partial class AnalysisProgressUserControl : UserControl
    {
        public AnalysisProgressUserControl()
        {
            InitializeComponent();
        }

        public AsyncAnalysisReport asyncresult { get; set; }

        private void timerUpdate_Tick(object sender, EventArgs e)
        {
            if (asyncresult == null)
            { return; }
            try
            {
                double percent = (double)asyncresult.TilesSearched / (double)asyncresult.MaxTiles;
                double coverage = (double)asyncresult.TilesFound / (double)asyncresult.TilesSearched;

                TimeSpan elapsed = DateTime.Now.Subtract(asyncresult.timeStarted);
                TimeSpan remaining = TimeSpan.FromMilliseconds(elapsed.TotalMilliseconds / percent);

                progressBar1.Value = (int)(percent * 100);
                labelTilesFound.Text = asyncresult.TilesFound.ToString();
                labelTileCoverage.Text = coverage + "%";
                labelTimeElapsed.Text = elapsed.ToString();
                labelTimeRemaining.Text = remaining.ToString();
            }
            catch { }
        }
    }
}
